Visit https://posit.cloud/content/5458223 to access the workshop material.1
Note
If you do not yet have a posit Cloud2 (previously known as Rstudio Cloud) account, you will have to sign up!
R is a programming language designed originally for statistical analyses.
Strengths
Weaknesses
<-We assign objects in R using the syntax object_name <- value
Note
This is analogous to object type. We can assign names to variables, vectors, matrices, dataframes, graphs, statistical models, etc. with <-.
R Core Group
R was formally released by the R Core Group in 1997: https://www.r-project.org/contributors.html
This group of 20-ish volunteers are the only people who can change the base (built-in) functionality of R.
Base functions are a set of functions in the R programming language that are included in the base package.
These functions provide a wide range of functionality, including mathematical operations, statistical functions, data manipulation, and input/output operations.
# A tibble: 344 × 8
species island bill_length_mm bill_depth_mm flipper_…¹ body_…² sex year
<fct> <fct> <dbl> <dbl> <int> <int> <fct> <int>
1 Adelie Torgersen 39.1 18.7 181 3750 male 2007
2 Adelie Torgersen 39.5 17.4 186 3800 fema… 2007
3 Adelie Torgersen 40.3 18 195 3250 fema… 2007
4 Adelie Torgersen NA NA NA NA <NA> 2007
5 Adelie Torgersen 36.7 19.3 193 3450 fema… 2007
6 Adelie Torgersen 39.3 20.6 190 3650 male 2007
7 Adelie Torgersen 38.9 17.8 181 3625 fema… 2007
8 Adelie Torgersen 39.2 19.6 195 4675 male 2007
9 Adelie Torgersen 34.1 18.1 193 3475 <NA> 2007
10 Adelie Torgersen 42 20.2 190 4250 <NA> 2007
# … with 334 more rows, and abbreviated variable names ¹flipper_length_mm,
# ²body_mass_g
Learn more about the data!
Learn more about the Palmer Penguins data set here.
Okay, but that’s kind of boring and doesn’t look quite right…
ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
)ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
) +
theme_bw()ggplot(data = penguins,
mapping = aes(x = bill_length_mm,
y = bill_depth_mm,
color = species,
shape = species
)
) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~ island) +
labs(x = "Bill Length (mm)",
y = "Bill depth (mm)",
title = "Penguin Bill Size",
color = "Species",
shape = "Species"
) +
scale_color_brewer(palette = "Dark2") +
scale_x_continuous(limits = c(30, 60),
breaks = seq(30,60,10)
) +
scale_y_continuous(limits = c(10, 25),
breaks = seq(10,25,5)
) +
theme_bw()Create a personal website with {Blogdown} or {Porfoliodown}
Write a book with {Bookdown}
And so much more!
Download and run the R installer for your operating system from CRAN:
If you are on Windows, you should also install the Rtools4 package; this will ensure you get fewer warnings later when installing packages.
More detailed instructions for Windows are available here
Download and install the latest version of RStudio for your operating system.
R, you can access help with a ? or help()R help on basic functionsClasses in the Department of Statistics with a focus on learning R:
Many other courses in the department make use of R software for the purpose of learning statistical concepts.